﻿using UnityEngine;
using System.Collections;

public class UIPartyItem : MonoBehaviour {

    public UISprite selectedBG;
    public UISprite spriteStatus;
    public UILabel contPeople;

    public PartyController PartyController 
    {
        get { return partyController; }
        set {
            partyController = value;
            SetIcon();
        } 
    }
    private PartyController partyController = null;

    public bool IsSelected
    {
        get { return isSelected; }
        set { 
            isSelected = value;
            selectedBG.gameObject.SetActive(value);
        }
    }
    private bool isSelected = false;

	void Start () {

	}

    private void SetIcon()
    {

        if (partyController.havingFun) {
            spriteStatus.spriteName = "singlehammer-h";
        } else {
            spriteStatus.spriteName = "peroni-h";
        }
        spriteStatus.MarkAsChanged();
    }
	
	void Update () {

        if (!partyController || contPeople == null) return;

        contPeople.text = partyController.PeopleInParty.Count.ToString();
	}

    public void ToggleSelection()
    {
        IsSelected = !IsSelected;
    }

    public void RefreshStatus()
    {
        SetIcon();
    }
}
